package com.qingke.beSuper2.utils;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;

public class PropertyManager {

	private static Map<String, PropertyManager> map = new HashMap<>();
	private Properties property;
	
	private PropertyManager(String identifier) {
		property = new Properties();
		try {
			property.load(new FileInputStream(identifier));
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public static synchronized PropertyManager getInstance(String identifier) {
		PropertyManager instance = map.get(identifier);
		if (instance == null) {
			instance = new PropertyManager(identifier);
			map.put(identifier, instance);
		}
		return instance;
	}
	
	public String getProperty(String key) {
		return property.getProperty(key);
	}
	
	public String[] getPropertyList(String key) {
		return property.getProperty(key).split(",");
	}
}
